<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    {include file="public/static" /}
</head>
<body>

{include file="public/nav" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">
                    {eq name="check.ArticlearticleClassifyAdd" value="1"}
                        <button class="layui-btn" onclick="common.openWindow('新增分类','{:url('Article/articleClassifyAdd',['pid'=>0])}','750','')">
                            <i class="layui-icon">&#xe654;</i>新增分类
                        </button>
                    {/eq}
                </div>
                <div class="layui-card-body layui-table-body">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th>标题</th>
                            <th>类型</th>
                            <th>状态</th>
                            <th>操作</th>
                        </thead>
                        <tbody>
                            {volist name="info" id="vo"}
                                <tr cate-id="{$vo.ac_id}" fid="{$vo.ac_pid}" level="{$vo.level}">
                                    <td><i class="layui-icon x-show" status='true'>|- </i>{$vo.ac_title}</td>
                                    <td>
                                        {if condition="$vo.ac_type eq 1"}
                                            <span class="layui-badge layui-bg-green">分类</span>
                                        {elseif condition="$vo.ac_type eq 2"/}
                                            <span class="layui-badge">文章</span>
                                        {else/}
                                            <span class="layui-badge layui-bg-cyan">链接</span>
                                        {/if}
                                    </td>
                                    <td>
                                        {eq name="vo.ac_status" value="1"}
                                            <span class="layui-badge layui-bg-green">启用</span>
                                        {else/}
                                            <span class="layui-badge">禁用</span>
                                        {/eq}
                                    </td>
                                    <td class="td-manage">
                                        {eq name="check.ArticlearticleClassifyAdd" value="1"}
                                            <a href="javascript:;" onclick="common.openWindow('新增下级','{:url('Article/articleClassifyAdd',['pid'=>$vo.ac_id])}','750','')" >
                                                <i class="layui-icon">&#xe654;</i>新增下级
                                            </a>
                                        {/eq}
                                        {eq name="check.ArticlearticleClassifyEdit" value="1"}
                                            <a href="javascript:;" onclick="common.openWindow('编辑分类','{:url('Article/articleClassifyEdit',['id'=>$vo.ac_id])}','750','')" >
                                                <i class="layui-icon">&#xe642;</i>编辑
                                            </a>
                                        {/eq}
                                        {eq name="check.ArticlearticleClassifyDel" value="1"}
                                            <a href="javascript:;" onclick="dataDel(this,'{$vo.ac_id}')" >
                                                <i class="layui-icon">&#xe640;</i>删除
                                            </a>
                                        {/eq}
                                    </td>
                                </tr>
                            {/volist}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    /*分类展开收起的分类的逻辑*/
    $(function() {
        common.tableVertical() //表格分级展示
    });
    /*全选*/
    common.selectCheckbox('checkbox','id[]');
    /*删除*/
    function dataDel(obj,id){
        layer.confirm('确认要删除这条数据吗？',function(){
            var index = layer.load();
            //发异步删除数据
            $.ajax({
               type:"post",
               url:"{:url('Article/articleClassifyDel')}",
               data:{id:id},
               dataType:'json',
               success:function (data) {
                   if(data.status === 1){
                       $(obj).parents("tr").remove();
                       layer.msg(data.info, {icon: 6,time:1500});
                   }else{
                       layer.msg(data.info, {icon: 5,time:1500});
                   }
                   layer.close(index);

               },
               error:function (data) {
                   console.log(data);
                   layer.msg("不好意思，出现了一点问题", {icon: 5});
               }
            });
        });
    }
</script>
</html>